from pydantic import BaseModel
from datetime import datetime
from typing import Optional, List
from .chapter import ChapterResponse

class QuestionBase(BaseModel):
    subject_id: int
    title: str
    content: str
    type: str
    difficulty: str
    answer: str
    analysis: str
    reference: str
    chapter_id: int

class QuestionCreate(QuestionBase):
    pass

class QuestionSourceBase(BaseModel):
    content: str
    position: dict
    chapter_content_id: int

class QuestionSourceResponse(QuestionSourceBase):
    id: int
    created_at: datetime
    modified_at: datetime

    class Config:
        orm_mode = True

class QuestionResponse(QuestionBase):
    id: int
    status: str
    sources: List[QuestionSourceResponse]
    chapter: ChapterResponse
    created_at: datetime
    modified_at: datetime

    class Config:
        orm_mode = True

class TextQuestionRequest(BaseModel):
    """文本生成题目请求"""
    content: str
    question_types: List[str]
    difficulty: str
    num_questions: int = 5

class TextQuestionResponse(BaseModel):
    """文本生成题目响应"""
    questions: List[dict] 